﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using He.Common;

namespace He.Web.manage.member
{
    public partial class list : He.Web.UI.Manage
    {
        protected int pageSize = 12;
        protected int page;
        protected int pcount;
        protected string keywords;
        protected void Page_Load(object sender, EventArgs e)
        {
            page = GetInt("page", 0);
            keywords = GetString("keywords");
            if (!IsPostBack)
            {
                chkLoginLevel("viewmember");

                CookieHelper.Set("LastListUrl", Request.RawUrl);    //保存最后一次访问的列表页Url

                ShowInfo();
            }
        }
        //搜索
        protected void btnSelect_Click(object sender, EventArgs e)
        {
            Response.Redirect("List.aspx?" + CombUrlTxt(txtKeywords.Text.Trim()) + "page=0");
        }
        protected void lbtnDel_Click(object sender, EventArgs e)
        {
            chkLoginLevel("delmember");
            He.BLL.member bll = new He.BLL.member();
            for (int i = 0; i < rptList.Items.Count; i++)
            {
                CheckBox cb = (CheckBox)rptList.Items[i].FindControl("Check");
                int id = int.Parse(((HiddenField)rptList.Items[i].FindControl("HiddenId")).Value);
                if (cb.Checked)
                {
                    He.Model.member model = bll.GetModel(id);
                    bll.Delete(id);
                }
            }
            SaveLogs("[会员管理]批量删除");
            JscriptPrint("批量删除成功啦！", Request.RawUrl, "Success");
        }
        private void ShowInfo()
        {
            this.txtKeywords.Text = this.keywords;
            BLL.member bll = new He.BLL.member();
            string strWhere = CombMemberSqlTxt(this.keywords);
            rptList.DataSource = bll.GetPageList(pageSize, page, strWhere, "id desc");
            rptList.DataBind();
            pcount = bll.GetRecordCount(strWhere);
        }
    }
}
